const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}



const judgeLink = arr =>{

  wx.request({
    url: "http://localhost:8080/data", //仅为示例，并非真实的接口地址
    data: {
    },
    header: {
      'content-type': 'application/json' // 默认值
    },
    success: function (res) {
      wx.hideLoading();
      wx.showToast({
        title: '加载完成',
        image: "../images/success.png",
        duration: 1500
      })
      arr.temp.setData({
        data:res.data,
        linkStatus: true
      })
    },
    fail: function (res) {
      wx.hideLoading();
      wx.showToast({
        title: '加载失败',
        image: "../images/fail.png",
        duration: 1500
      })
      arr.temp.setData({
        linkStatus: false
      })
    }
  })
}

module.exports = {
  formatTime: formatTime,
  judgeLink: judgeLink
}

